@extends('layouts.app')

@section('title')
    后台-物品新增
@stop

@section('extcss')
    <!--ext css-->
    <!-- Select2 -->
    <link href="{{asset("vendors/select2/dist/css/select2.min.css")}}" rel="stylesheet">
    <!--Bootstrap-fileinput-->
    <link href="http://cdn.bootcss.com/bootstrap-fileinput/4.3.1/css/fileinput.min.css" rel="stylesheet">
    <!-- Switchery -->
    <link href="{{asset("vendors/switchery/dist/switchery.min.css")}}" rel="stylesheet">
    <!-- /ext css-->
@stop

@section('content')
    <!-- page content -->
    <div class="right_col" role="main">
        <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>物品管理</h3>
                </div>

                <div class="title_right">
                    &nbsp;
                </div>
            </div>
            <div class="clearfix"></div>

            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>新增入库</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
                            <form id="goodsForm" method="post" action="{{url('system/goods')}}" class="form-horizontal form-label-left" enctype="multipart/form-data" novalidate>
                                {!! csrf_field() !!}
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="serial">厂家编号 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="text" id="serial" name="serial" class="form-control col-md-7 col-xs-12" placeholder="物品序号" required="">
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="serial">内部代号 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="text" id="symbol" name="symbol" class="form-control col-md-7 col-xs-12" placeholder="内部代号" required="">
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">商品名称 <span class="required"> </span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="text" id="name" name="name" placeholder="上衣圆领T恤" class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="category">商品分类 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <select id="category" name="category" class="select2_single form-control" required="">
                                            <option value="" selected>请选择分类</option>
                                            <optgroup label="上衣">
                                                @foreach($dicStyle_up as $item)
                                                    <option value="{{$item->val}}">{{$item->key}}</option>
                                                @endforeach
                                            </optgroup>
                                            <optgroup label="裤子">
                                                @foreach($dicStyle_down as $item)
                                                    <option value="{{$item->val}}">{{$item->key}}</option>
                                                @endforeach
                                            </optgroup>
                                        </select>
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="category">风格 <span class="required"></span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <select id="style" name="style" class="select2_single form-control" required="">
                                            <option value="" selected>请选择风格</option>
                                            @foreach($dicStyle as $item)
                                                <option value="{{$item->val}}">{{$item->key}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="category">穿着位置 <span class="required"></span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <select id="postion" name="postion" class="select2_single form-control" required="">
                                            <option value="" selected>请选择分类穿着位置</option>
                                            @foreach($dicPostion as $item)
                                                <option value="{{$item->val}}">{{$item->key}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="brand">商品品牌 <span class="required"> </span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="text" id="brand" name="brand" placeholder="杰克琼斯" class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="color">商品颜色<span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <select id="color" name="color" class="select2_single form-control" tabindex="-1" required="">
                                            <option value="" selected>请选择颜色</option>
                                            @foreach($dicColor as $item)
                                                <option value="{{$item->val}}">{{$item->key}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="size">商品尺码 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <select id="size" name="size" class="select2_single form-control" tabindex="-1" required="">
                                            <option value="" selected>请选择尺码</option>
                                            <optgroup label="上衣">
                                                @foreach($dicSize_up as $item)
                                                    <option value="{{$item->val}}">{{$item->key}}</option>
                                                @endforeach
                                            </optgroup>
                                            <optgroup label="裤子">
                                                @foreach($dicSize_down as $item)
                                                    <option value="{{$item->val}}">{{$item->key}}</option>
                                                @endforeach
                                            </optgroup>
                                        </select>
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3" for="number">数量<span class="required">*</span></label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="number" id="number" name="number" placeholder="0" class="form-control col-md-7 col-xs-12" data-parsley-min="1" required="">
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3" for="price">进货价<span class="required">*</span></label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="number" id="price" name="price" placeholder="0" class="form-control col-md-7 col-xs-12" data-parsley-min="1" required="">
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="state">状态 <span class="required"> </span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="checkbox" id="state" name="state" class="js-switch" checked /> 是否上架
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="picurl">商品图片上传 <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <input type="file" id="picurl" name="picurl" class="file" data-show-upload="false" accept="image/*">
                                    </div>
                                </div>
                                <div class="item form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="remark">备注 <span class="required"></span>
                                    </label>
                                    <div class="col-md-6 col-sm-6 col-xs-12">
                                        <textarea id="remark" name="remark" class="form-control col-md-7 col-xs-12" data-trigger="keyup" data-parsley-length="[20, 200]"></textarea>
                                    </div>
                                </div>
                                <div class="ln_solid"></div>
                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-3">
                                        <div class="col-md-6"><button type="submit" class="btn btn-success">提交</button></div>
                                        <div class="col-md-6"><button type="reset" class="btn btn-default">重置</button></div>
                                    </div>
                                </div>
                                <div class="ln_solid"></div>
                                <div class="row">
                                    @if($errors->any())
                                        <ul class="list-group">
                                            @foreach($errors->all() as $error)
                                                <li class="list-group-item list-group-item-danger">{{$error}}</li>
                                            @endforeach
                                        </ul>
                                    @endif
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /page content -->
@stop

@section('extjs')
    <!--ext js-->
    <!-- Select2 -->
    <script src="{{asset("vendors/select2/dist/js/select2.full.min.js")}}"></script>
    <!-- Switchery -->
    <script src="{{asset("vendors/switchery/dist/switchery.min.js")}}"></script>
    <!-- Parsley -->
    <script src="{{asset("vendors/parsleyjs/dist/parsley.min.js")}}"></script>
    <script src="{{asset("vendors/parsleyjs/dist/i18n/zh_cn.js")}}"></script>
    <!--Bootstrap-fileinput-->
    <script src="http://cdn.bootcss.com/bootstrap-fileinput/4.3.1/js/fileinput.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap-fileinput/4.3.1/js/fileinput_locale_zh.min.js"></script>

    <!--Bootstrap-fileinput-->
    <script>
        $("#picurl").fileinput({
            language: "zh",
            maxFileCount: 1,
            previewFileType: "image",
            allowedFileExtensions: ["jpg", "png", "gif"],
        });
    </script>
    <!-- /Bootstap-fileinput-->

    <!--Parsley-->
    <script type="text/javascript">
        $(function () {
            $('#goodsForm').parsley().on('field:validated', function() {
                var ok = $('.parsley-error').length === 0;
                $('.bs-callout-info').toggleClass('hidden', !ok);
                $('.bs-callout-warning').toggleClass('hidden', ok);
            }).on('form:submit', function() {
                $(this).submit();
          });
        });
    </script>
    <!-- /Parsley-->
    <!-- /ext js-->
@stop